<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>


<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<meta name="theme-color" content="#f8f5ec" />
<meta name="msapplication-navbutton-color" content="#f8f5ec">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="#f8f5ec">



  <meta name="description" content="animation与transform、transition"/>




  <meta name="keywords" content="animation与transform、transition" />










  <link rel="alternate" href="/teresa/atom.xml" title="Teresa">




  <link rel="shortcut icon" type="image/x-icon" href="/teresa/favicon.ico?v=2.9.0" />



<link rel="canonical" href="https://littlefaye.gitee.io/teresa/2018/10/11/animation与transform/"/>



  <link rel="stylesheet" type="text/css" href="/teresa/lib/fancybox/jquery.fancybox.css" />




  <link rel="stylesheet" type="text/css" href="/teresa/lib/nprogress/nprogress.min.css" />



<link rel="stylesheet" type="text/css" href="/teresa/css/style.css?v=2.9.0" />



  
  <script id="baidu_analytics">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?9b4723f0455add81c1300727d6fe2f0f";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




  <script id="baidu_push">
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>





  <script src="//cdn1.lncld.net/static/js/3.1.1/av-min.js"></script>
  <script id="leancloud">
    AV.init({
      appId: "q8I1nPpo7445tVF84mvOlAyj-gzGzoHsz",
      appKey: "i9j12HoNltgi5uq4DLvonO0h"
    });
  </script>




<script>
  window.config = {"title":"Teresa","subtitle":null,"description":"about fe","author":"Teresa-哼哼","language":"zh-CN","timezone":null,"url":"https://littlefaye.gitee.io/teresa","root":"/teresa/","permalink":":year/:month/:day/:title/","permalink_defaults":null,"source_dir":"source","public_dir":"public","tag_dir":"tags","archive_dir":"archives","category_dir":"categories","code_dir":"downloads/code","i18n_dir":":lang","skip_render":null,"new_post_name":":title.md","default_layout":"post","titlecase":false,"external_link":true,"filename_case":0,"render_drafts":false,"post_asset_folder":false,"relative_link":false,"future":true,"highlight":{"enable":true,"auto_detect":false,"line_number":true,"tab_replace":null,"first_line_number":"always1"},"default_category":"uncategorized","category_map":null,"tag_map":null,"date_format":"YYYY-MM-DD","time_format":"HH:mm:ss","per_page":10,"pagination_dir":"page","theme":"even","deploy":{"type":"git","repo":"https://gitee.com/littleFaye/Teresa.git"},"ignore":[],"keywords":null,"index_generator":{"per_page":10,"order_by":"-date","path":""},"archive_generator":{"per_page":10,"yearly":true,"monthly":true,"daily":false},"tag_generator":{"per_page":10},"category_generator":{"per_page":10},"marked":{"gfm":true,"pedantic":false,"sanitize":false,"tables":true,"breaks":true,"smartLists":true,"smartypants":true,"modifyAnchors":"","autolink":true},"server":{"port":4000,"log":false,"ip":"0.0.0.0","compress":false,"header":true},"since":2015,"favicon":"/favicon.ico","rss":false,"menu":{"Home":"/","Archives":"/archives/","Tags":"/tags","Categories":"/categories","About":"/about"},"color":"Default","toc":true,"fancybox":true,"pjax":true,"copyright":{"enable":true,"license":"<a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc/4.0/\" target=\"_blank\">知识共享署名-非商业性使用 4.0 国际许可协议</a>"},"reward":{"enable":false,"qrCode":{"wechat":null,"alipay":null}},"social":{"email":"1748711164@qq.com","stack-overflow":null,"twitter":null,"facebook":null,"linkedin":null,"google":null,"github":"https://github.com/Faye0807","weibo":null,"zhihu":null,"douban":null,"pocket":null,"tumblr":null,"instagram":null},"leancloud":{"app_id":"q8I1nPpo7445tVF84mvOlAyj-gzGzoHsz","app_key":"i9j12HoNltgi5uq4DLvonO0h"},"baidu_analytics":"9b4723f0455add81c1300727d6fe2f0f","baidu_verification":null,"google_analytics":null,"google_verification":null,"disqus_shortname":null,"changyan":{"appid":null,"appkey":null},"livere_datauid":null,"version":"2.9.0"};
</script>

    <title> animation与transform、transition - Teresa </title>
  </head>

  <body><div id="mobile-navbar" class="mobile-navbar">
  <div class="mobile-header-logo">
    <a href="/teresa/." class="logo">Teresa</a>
  </div>
  <div class="mobile-navbar-icon">
    <span></span>
    <span></span>
    <span></span>
  </div>
</div>

<nav id="mobile-menu" class="mobile-menu slideout-menu">
  <ul class="mobile-menu-list">
    
      <a href="/teresa/">
        <li class="mobile-menu-item">
          
          
            首页
          
        </li>
      </a>
    
      <a href="/teresa/archives/">
        <li class="mobile-menu-item">
          
          
            归档
          
        </li>
      </a>
    
      <a href="/teresa/tags">
        <li class="mobile-menu-item">
          
          
            标签
          
        </li>
      </a>
    
      <a href="/teresa/categories">
        <li class="mobile-menu-item">
          
          
            分类
          
        </li>
      </a>
    
      <a href="/teresa/about">
        <li class="mobile-menu-item">
          
          
            关于
          
        </li>
      </a>
    
  </ul>
</nav>

    <div class="container" id="mobile-panel">
      <header id="header" class="header"><div class="logo-wrapper">
  <a href="/teresa/." class="logo">Teresa</a>
</div>

<nav class="site-navbar">
  
    <ul id="menu" class="menu">
      
        <li class="menu-item">
          <a class="menu-item-link" href="/teresa/">
            
            
              首页
            
          </a>
        </li>
      
        <li class="menu-item">
          <a class="menu-item-link" href="/teresa/archives/">
            
            
              归档
            
          </a>
        </li>
      
        <li class="menu-item">
          <a class="menu-item-link" href="/teresa/tags">
            
            
              标签
            
          </a>
        </li>
      
        <li class="menu-item">
          <a class="menu-item-link" href="/teresa/categories">
            
            
              分类
            
          </a>
        </li>
      
        <li class="menu-item">
          <a class="menu-item-link" href="/teresa/about">
            
            
              关于
            
          </a>
        </li>
      
    </ul>
  
</nav>

      </header>

      <main id="main" class="main">
        <div class="content-wrapper">
          <div id="content" class="content">
            
  
  <article class="post">
    <header class="post-header">
      <h1 class="post-title">
        
          animation与transform、transition
        
      </h1>

      <div class="post-meta">
        <span class="post-time">
          2018-10-11
        </span>
        
          <div class="post-category">
            
              <a href="/teresa/categories/CSS/">CSS</a>
            
          </div>
        
        
        <div class="post-visits"
             data-url="/teresa/2018/10/11/animation与transform/"
             data-title="animation与transform、transition">
            阅读次数 0
          </div>
        
      </div>
    </header>

    
    
  <div class="post-toc" id="post-toc">
    <h2 class="post-toc-title">文章目录</h2>
    <div class="post-toc-content">
      <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#transform-变换"><span class="toc-text">transform 变换</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#倾斜：skew-x-angle-y-angle-skewX-angle-skewY-angle"><span class="toc-text">倾斜：skew(x-angle,y-angle),skewX(angle),skewY(angle)</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#示例"><span class="toc-text">示例</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#旋转：rotate-angle-rotateX-angle-rotateY-angle-rotateZ-angle-（与rotate-angle-效果相同）"><span class="toc-text">旋转：rotate(angle),rotateX(angle),rotateY(angle),rotateZ(angle)（与rotate(angle)效果相同）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#缩放：scale-x-y-scaleX-x-scaleY-y-scaleZ-z"><span class="toc-text">缩放：scale(x,y),scaleX(x),scaleY(y),scaleZ(z)</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#移动：translate-x-y-translateX-x-translateY-y-translateZ-z-translate3d-x-y-z"><span class="toc-text">移动：translate(x,y), translateX(x), translateY(y), translateZ(z), translate3d(x,y,z)</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#transform-origin：更改一个元素变形的原点"><span class="toc-text">transform-origin：更改一个元素变形的原点</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#transition-过渡"><span class="toc-text">transition 过渡</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#animation-动画"><span class="toc-text">animation 动画</span></a></li></ol>
    </div>
  </div>



    <div class="post-content">
      
        <h1 id="transform-变换"><a href="#transform-变换" class="headerlink" title="transform 变换"></a>transform 变换</h1><h2 id="倾斜：skew-x-angle-y-angle-skewX-angle-skewY-angle"><a href="#倾斜：skew-x-angle-y-angle-skewX-angle-skewY-angle" class="headerlink" title="倾斜：skew(x-angle,y-angle),skewX(angle),skewY(angle)"></a>倾斜：skew(x-angle,y-angle),skewX(angle),skewY(angle)</h2><ul>
<li>skewX(angle)：元素高不变，x方向即宽被拉长</li>
<li>skewY(angle)：元素宽不变，y方向即高被拉长</li>
<li>skew(x-angle,y-angle)是前两个的结合，</li>
<li>skew(x deg,-x deg)会产生一个逆时针旋转x度且被放大的效果</li>
<li>角度值可以是负值，skewX(10deg)与skewX(-10deg)倾斜角度关于y轴对称；</li>
<li>skewX(90deg)、skewX(-90deg)、skewX(270deg) 元素消失</li>
<li>skewX(91deg) == skewX(-89deg)<h2 id="示例"><a href="#示例" class="headerlink" title="示例"></a>示例</h2>原图</li>
</ul>
<p><img src="https://static.oschina.net/uploads/space/2018/0304/201402_dIRA_2994006.png" alt="原图"></p>
<p>transform:skewX(30deg)</p>
<p><img src="https://static.oschina.net/uploads/space/2018/0304/185713_dZOS_2994006.png" alt="skewX(30deg)"></p>
<p>transform:skewY(30deg)</p>
<p><img src="https://static.oschina.net/uploads/space/2018/0304/185928_Yinh_2994006.png" alt="skewY(30deg)"></p>
<p>transform:skew(30deg,-30deg)</p>
<p><img src="https://static.oschina.net/uploads/space/2018/0304/190910_UAS2_2994006.png" alt="skew(30deg,-30deg)"></p>
<p>ransform:skew(-30deg,30deg)</p>
<p><img src="https://static.oschina.net/uploads/space/2018/0304/190946_zIRD_2994006.png" alt="skew(-30deg,30deg)"></p>
<h2 id="旋转：rotate-angle-rotateX-angle-rotateY-angle-rotateZ-angle-（与rotate-angle-效果相同）"><a href="#旋转：rotate-angle-rotateX-angle-rotateY-angle-rotateZ-angle-（与rotate-angle-效果相同）" class="headerlink" title="旋转：rotate(angle),rotateX(angle),rotateY(angle),rotateZ(angle)（与rotate(angle)效果相同）"></a>旋转：rotate(angle),rotateX(angle),rotateY(angle),rotateZ(angle)（与rotate(angle)效果相同）</h2><p>绕对应轴旋转<br>rotate() == rotateZ() 在平面内顺时针旋转</p>
<h2 id="缩放：scale-x-y-scaleX-x-scaleY-y-scaleZ-z"><a href="#缩放：scale-x-y-scaleX-x-scaleY-y-scaleZ-z" class="headerlink" title="缩放：scale(x,y),scaleX(x),scaleY(y),scaleZ(z)"></a>缩放：scale(x,y),scaleX(x),scaleY(y),scaleZ(z)</h2><p>沿对应轴方向缩放（根据变换原点不同，方向不同；比如origin是left的时候 x轴方向的缩放是向右缩放；若默认在元素中心，则x轴的缩放是从中心向两边同时缩放）<br>z方向的缩放2d看不出效果<br>接受值：数值 不接受百分比</p>
<h2 id="移动：translate-x-y-translateX-x-translateY-y-translateZ-z-translate3d-x-y-z"><a href="#移动：translate-x-y-translateX-x-translateY-y-translateZ-z-translate3d-x-y-z" class="headerlink" title="移动：translate(x,y), translateX(x), translateY(y), translateZ(z), translate3d(x,y,z)"></a>移动：translate(x,y), translateX(x), translateY(y), translateZ(z), translate3d(x,y,z)</h2><p>沿对应轴方向位移<br>z方向2d变换看不出效果<br>接受值： 30px或者百分比（百分比是以自身宽高为基数）</p>
<h2 id="transform-origin：更改一个元素变形的原点"><a href="#transform-origin：更改一个元素变形的原点" class="headerlink" title="transform-origin：更改一个元素变形的原点"></a>transform-origin：更改一个元素变形的原点</h2><p>transform-origin: left;<br>transform-origin: 20px;<br>transform-origin: 40px  left;(水平，垂直)</p>
<h1 id="transition-过渡"><a href="#transition-过渡" class="headerlink" title="transition 过渡"></a>transition 过渡</h1><blockquote>
<p><a href="https://developer.mozilla.org/zh-CN/docs/Web/CSS/CSS_Transitions/Using_CSS_transitions" target="_blank" rel="noopener">参考</a></p>
</blockquote>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">transition</span>: &lt;<span class="selector-tag">property</span>属性名&gt; &lt;<span class="selector-tag">duration</span>过渡时长&gt; &lt;<span class="selector-tag">timing-function</span>过渡时间线&gt; &lt;<span class="selector-tag">delay</span>&gt;;</span><br></pre></td></tr></table></figure>
<ul>
<li>transition-property: width, left;</li>
<li>transition-timing-function<ul>
<li>ease 中间快两端慢</li>
<li>linear 匀速</li>
<li>step-end 直接跳到最后一帧</li>
<li>step(4,end) 分四步完成过渡</li>
</ul>
</li>
<li>transition-duration: 3s</li>
<li>transition-delay: 3s<br>可以合并写多个属性</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">transition</span><span class="selector-pseudo">:width</span> 2<span class="selector-tag">s</span>, <span class="selector-tag">height</span> 2<span class="selector-tag">s</span>;</span><br></pre></td></tr></table></figure>
<h1 id="animation-动画"><a href="#animation-动画" class="headerlink" title="animation 动画"></a>animation 动画</h1><blockquote>
<p><a href="http://www.runoob.com/cssref/css3-pr-animation.html" target="_blank" rel="noopener">参考</a></p>
</blockquote>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">animation</span>: <span class="selector-tag">name</span> <span class="selector-tag">duration</span> <span class="selector-tag">timing-function</span> <span class="selector-tag">delay</span> <span class="selector-tag">iteration-count</span> <span class="selector-tag">direction</span> <span class="selector-tag">fill-mode</span> <span class="selector-tag">play-state</span>;</span><br></pre></td></tr></table></figure>
<ul>
<li>animation-name    指定要绑定到选择器的关键帧的名称<ul>
<li>默认值：none</li>
</ul>
</li>
<li>animation-duration    动画指定需要多少秒或毫秒完成<ul>
<li>3s<br>- 默认 0</li>
</ul>
</li>
<li>animation-timing-function    设置动画将如何完成一个周期<ul>
<li>linear 匀速</li>
<li>ease 默认 中间快两边慢</li>
<li>ease-in 低速开始</li>
<li>ease-out 低速结束</li>
<li>ease-in-out 低俗开始，低速结束（与ease区别大概是中间速度没有ease高）</li>
<li>cubic-bezier(n,n,n,n) n是0-1的值</li>
</ul>
</li>
<li>animation-delay    设置动画在启动前的延迟间隔。<ul>
<li>3s<br>- 默认 0</li>
</ul>
</li>
<li>animation-iteration-count    定义动画的播放次数。 <ul>
<li>默认 1</li>
<li>n 整数表示播放n次</li>
<li>infinite 无限循环播放</li>
</ul>
</li>
<li>animation-direction    指定是否应该轮流反向播放动画。<ul>
<li>normal 默认值</li>
<li>reverse 方向播放</li>
<li>alternate 在奇数次 正常播放，在偶数次 反向播放</li>
<li>alternate-reverse 在偶数次正常播放，在奇数次 反向播放</li>
<li>initial 设置该属性为他的默认值</li>
<li>inherit</li>
</ul>
</li>
<li>animation-fill-mode    规定当动画不播放时（当动画完成时，或当动画有一个延迟未开始播放时），要应用到元素的样式。<ul>
<li>none 默认 不会应用任何样式（其实就是在动画结束后，画面回到动画的第一帧</li>
<li>forwards 动画结束后，停留在最后一帧</li>
<li>backwards 动画结束后，停留到动画开始的第一帧</li>
<li>both forwards和backwards两个方向上扩展动画属性</li>
</ul>
</li>
<li>animation-play-state    指定动画是否正在运行或已暂停。<ul>
<li>running 默认 运行</li>
<li>paused 暂停 当属性值为paused时，动画停留在被暂停的那一帧</li>
</ul>
</li>
<li>initial    设置属性为其默认值。 阅读关于 initial的介绍。</li>
<li>inherit    从父元素继承属性。 阅读关于 initinherital的介绍。</li>
</ul>

      
    </div>

    
      
      

  <div class="post-copyright">
    <p class="copyright-item">
      <span>原文作者: </span>
      <a href="https://littlefaye.gitee.io/teresa">Teresa-哼哼</a>
    </p>
    <p class="copyright-item">
      <span>原文链接: </span>
      <a href="https://littlefaye.gitee.io/teresa/2018/10/11/animation与transform/">https://littlefaye.gitee.io/teresa/2018/10/11/animation与transform/</a>
    </p>
    <p class="copyright-item">
      <span>许可协议: </span>
      
      <a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/" target="_blank">知识共享署名-非商业性使用 4.0 国际许可协议</a>
    </p>
  </div>



      
      
    

    
      <footer class="post-footer">
        
          <div class="post-tags">
            
              <a href="/teresa/tags/CSS/">CSS</a>
            
          </div>
        
        
        
  <nav class="post-nav">
    
      <a class="prev" href="/teresa/2018/10/11/CSS实现宽度自适应100-，宽高16-9的比例的矩形/">
        <i class="iconfont icon-left"></i>
        <span class="prev-text nav-default">CSS实现宽度自适应100%，宽高16:9的比例的矩形</span>
        <span class="prev-text nav-mobile">上一篇</span>
      </a>
    
    
      <a class="next" href="/teresa/2018/09/29/XHR实现ajax与jsonp/">
        <span class="next-text nav-default">XHR实现ajax与jsonp</span>
        <span class="prev-text nav-mobile">下一篇</span>
        <i class="iconfont icon-right"></i>
      </a>
    
  </nav>

      </footer>
    

  </article>


          </div>
          
  <div class="comments" id="comments">
    
  </div>


        </div>
      </main>

      <footer id="footer" class="footer">

  <div class="social-links">
    
      
        
          <a href="mailto:1748711164@qq.com" class="iconfont icon-email" title="email"></a>
        
      
    
      
    
      
    
      
    
      
    
      
    
      
        
          <a href="https://github.com/Faye0807" class="iconfont icon-github" title="github"></a>
        
      
    
      
    
      
    
      
    
      
    
      
    
      
    
    
    
  </div>


<div class="copyright">
  <span class="power-by">
    由 <a class="hexo-link" href="https://hexo.io/">Hexo</a> 强力驱动
  </span>
  <span class="division">|</span>
  <span class="theme-info">
    主题 - 
    <a class="theme-link" href="https://github.com/ahonn/hexo-theme-even">Even</a>
  </span>

  <span class="copyright-year">
    
    &copy; 
     
      2015 - 
    
    2018

    <span class="heart">
      <i class="iconfont icon-heart"></i>
    </span>
    <span class="author">Teresa-哼哼</span>
  </span>
</div>

      </footer>

      <div class="back-to-top" id="back-to-top">
        <i class="iconfont icon-up"></i>
      </div>
    </div>

    
  
  

  



    
  



  
  





  
    <script type="text/javascript" src="/teresa/lib/jquery/jquery.min.js"></script>
  

  
    <script type="text/javascript" src="/teresa/lib/slideout/slideout.js"></script>
  

  
    <script type="text/javascript" src="/teresa/lib/fancybox/jquery.fancybox.pack.js"></script>
  

  
    <script type="text/javascript" src="/teresa/lib/pjax/jquery.pjax.min.js"></script>
  

  
    <script type="text/javascript" src="/teresa/lib/nprogress/nprogress.min.js"></script>
  


    <script type="text/javascript" src="/teresa/js/src/even.js?v=2.9.0"></script>

  </body>
</html>
